from sqlalchemy import Column, text, TEXT
from sqlalchemy.dialects.mysql import INTEGER, TINYINT
from field_types.base_types import String
from models.base_model import Base


class SystemUsers(Base):
    """
    文件管理系统用户表
    """
    __tablename__ = 'system_users'
    id = Column(INTEGER(11), primary_key=True)
    guid = Column(String(40, 'utf8mb4_unicode_ci'))
    username = Column(String(40, 'utf8mb4_unicode_ci'))
    name = Column(String(128, 'utf8mb4_unicode_ci'))
    mail = Column(String(64, 'utf8mb4_unicode_ci'))
    phone = Column(String(64, 'utf8mb4_unicode_ci'))
    role = Column(TINYINT(1), server_default=text("'0'"))
    last_login_time = Column(INTEGER(11))
    create_time = Column(INTEGER(11))
    create_user_id = Column(INTEGER(11))
    last_update_time = Column(INTEGER(11))
    last_update_user_id = Column(INTEGER(11))
    is_delete = Column(TINYINT(1), server_default=text("'0'"))

    @property
    def get_condition_fields(self):
        return ["name", "username", "mail", "phone"]

    @property
    def no_display_field(self):
        """
        查询时不会返回的字段
        """
        return ["create_time", "create_user_id", "last_update_time", "last_update_user_id"]